/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package me.panpf.sketch.sample.bean;

import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;

import me.panpf.sketch.util.TextUtils;
import org.jetbrains.annotations.Nullable;

/**
 * BaiduImageSearchResult
 */
public class BaiduImageSearchResult {
    @SerializedName("listNum")
    private int total;
    @SerializedName("data")
    @Nullable
    private List<BaiduImage> imageList = new ArrayList<BaiduImage>();

    public int getTotal() {
        return this.total;
    }

    public void setTotal(int var1) {
        this.total = var1;
    }

    @Nullable
    public List<BaiduImage> getImageList() {
        return this.imageList;
    }

    public void setImageList(@Nullable List<BaiduImage> var1) {
        this.imageList = var1;
    }

    /**
     * BaiduImage
     */
    public static final class BaiduImage {
        @SerializedName("thumbURL")
        @Nullable
        private String thumbURL;
        @SerializedName("middleURL")
        @Nullable
        private String middleURL;
        @SerializedName("hoverURL")
        @Nullable
        private String hoverURL;
        @SerializedName("replaceUrl")
        private List<ReplaceUrl> replaceUrlList = new ArrayList<ReplaceUrl>();
        @SerializedName("width")
        private int width;
        @SerializedName("height")
        private int height;

        @Nullable
        public String getThumbURL() {
            return this.thumbURL;
        }

        @Nullable
        public String getMiddleURL() {
            return this.middleURL;
        }

        @Nullable
        public String getHoverURL() {
            return this.hoverURL;
        }

        @Nullable
        public List<ReplaceUrl> getReplaceUrlList() {
            return this.replaceUrlList;
        }

        public void setReplaceUrlList(@Nullable List<ReplaceUrl> var1) {
            this.replaceUrlList = var1;
        }

        public int getWidth() {
            return this.width;
        }

        public int getHeight() {
            return this.height;
        }

        /**
         * getUrl
         *
         * @return String
         */
        @Nullable
        public String getUrl() {
            String urlVar;
            if (TextUtils.isEmpty(hoverURL)) {
                return null;
            }
            if (!this.hoverURL.equals(this.middleURL) && !this.hoverURL.equals(this.thumbURL)) {
                urlVar = this.hoverURL;
            } else {
                if (this.replaceUrlList == null || this.replaceUrlList.isEmpty()) {
                    urlVar = null;
                } else {
                    urlVar = this.replaceUrlList.get(0).getObjUrl();
                }
            }

            return urlVar;
        }
    }

    /**
     * ReplaceUrl
     */
    public static final class ReplaceUrl {
        @SerializedName("ObjURL")
        @Nullable
        private String objUrl;

        @Nullable
        public String getObjUrl() {
            return this.objUrl;
        }

        public void setObjUrl(@Nullable String var1) {
            this.objUrl = var1;
        }
    }
}
